﻿using Quartz;
using System;
using System.Threading.Tasks;

namespace FtpUploadWeb.Common
{
    /// <summary>
    /// 实现Quartz中的IJob接口
    /// </summary>
    [DisallowConcurrentExecutionAttribute]
    public class BackupJob : IJob
    {
        public Task Execute(IJobExecutionContext context)
        {
            return Task.Run(() =>
            {
                try
                {
                    //压缩文件夹
                    TaskManage.WriteTextLog("BackupJob", "开始压缩");
                    ZipFileHelper.UpZip();

                    //上传文件
                    TaskManage.WriteTextLog("BackupJob", "开始上传");
                    FtpHelper.ConnectionFtp();
                    FtpHelper.Upload();
                }
                catch (Exception ex)
                {
                    TaskManage.WriteTextLog("BackupJob", ex.ToString());
                }
            });
        }
    }
}
